﻿<%
class LinkGroupClass
    public blogId
    public groupId,  groupName, groupDesc, displaySeq
    public links
    
    
    public function toArray()
        dim array(6)
        
        array(0) = blogId
        array(1) = groupId
        array(2) = groupName
        array(3) = groupDesc
        array(4) = displaySeq
        

        dim linkCount, i, link, linkArray
        linkCount = ubound(links)

        'response.write groupName
        'response.write linkCount
        'response.end

        redim linkArray(linkCount) 
        if linkCount>0 then
            for i=0 to linkCount-1
                if not isEmpty(links(i)) then
                    set link = links(i)
                    linkArray(i) = link.toArray()
                end if    
            next
        end if    
        array(5) = linkArray
        
        toArray = array
    end function
    
    public function build(array)
        build = false
        if isEmpty(array) or not isArray(array) then
            exit function
        end if
        if ubound(array)<6 then
            exit function
        end if    
    
        blogId      = array(0) 
        groupId     = array(1) 
        groupName   = array(2) 
        groupDesc   = array(3) 
        displaySeq  = array(4) 
        
        dim linkCount, i, link, linkArray
        linkArray = array(5)
        linkCount = ubound(linkArray)
        redim links(linkCount) 
        for i=0 to linkCount-1
            set link = new LinkClass
            link.build(linkArray(i))
            set links(i) = link
        next
            
        build = true
    end function
    
    public function buildFromRS(rs)
        buildFromRS = false
        if isEmpty(rs) or not isObject(rs) then
            exit function
        end if
        if rs.bof or rs.eof then
            exit function
        end if    
        
        groupId      = rs("group_id")
        
        on error resume next
        
        blogId      = rs("blog_id")
        groupName    = rs("group_name") 
        groupDesc    = rs("group_desc")
        linkImg     = rs("link_img")
        displaySeq  = rs("display_seq")
        
        on error goto 0
        
        buildFromRS = true    
    end function
end class
%>